PLANCK

Overview

The PLANCK function computes values for the Planck discrete exponential distribution, a discrete probability distribution used in statistical mechanics and quantum physics contexts. This distribution models the probability of finding a system in a particular quantum state based on its energy level, with applications in analyzing thermal radiation and energy quantization phenomena.

The Planck distribution is implemented via SciPy’s scipy.stats.planck module. The probability mass function (PMF) is defined as:

f(k) = (1 - e^{-\lambda}) e^{-\lambda k}

for k \geq 0 and shape parameter \lambda > 0. This discrete distribution can be viewed as a shifted geometric distribution with p = 1 - e^{-\lambda}, offset by loc = -1.

The parameter \lambda controls the rate of exponential decay: larger values concentrate probability mass near zero, while smaller values produce a more spread-out distribution. The distribution is named after physicist Max Planck, whose work on black-body radiation and energy quanta laid the foundation for quantum mechanics. The discrete Planck distribution arises naturally when modeling the number of energy quanta (photons) in a mode of thermal radiation at thermodynamic equilibrium.

The function supports multiple output modes including the PMF, cumulative distribution function (CDF), survival function (SF), inverse CDF (ICDF/percentile function), inverse survival function (ISF), and summary statistics (mean, variance, standard deviation, and median). The optional loc parameter shifts the distribution along the integer axis.

This example function is provided as-is without any representation of accuracy.

Excel Usage

=PLANCK(k, lambda_, planck_mode, loc)
  • k (list[list], required): Value(s) at which to evaluate the distribution, or probability value for ICDF/ISF modes.
  • lambda_ (float, required): Shape parameter (must be > 0).
  • planck_mode (str, optional, default: “pmf”): Output type for the distribution calculation.
  • loc (float, optional, default: 0): Location parameter that shifts the distribution.

Returns (float): Distribution result (float), or error message string.

Examples

Example 1: PMF at k=2, lambda=0.5

Inputs:

k lambda_ planck_mode loc
2 0.5 pmf 0

Excel formula:

=PLANCK(2, 0.5, "pmf", 0)

Expected output:

0.1455

Example 2: CDF at k=2, lambda=0.5

Inputs:

k lambda_ planck_mode loc
2 0.5 cdf 0

Excel formula:

=PLANCK(2, 0.5, "cdf", 0)

Expected output:

0.7769

Example 3: Survival function at k=2, lambda=0.5

Inputs:

k lambda_ planck_mode loc
2 0.5 sf 0

Excel formula:

=PLANCK(2, 0.5, "sf", 0)

Expected output:

0.2231

Example 4: Inverse CDF for probability=0.5, lambda=0.5

Inputs:

k lambda_ planck_mode loc
0.5 0.5 icdf 0

Excel formula:

=PLANCK(0.5, 0.5, "icdf", 0)

Expected output:

1

Example 5: Array input for k

Inputs:

k lambda_ planck_mode loc
1 2 0.5 pmf 0
3 4

Excel formula:

=PLANCK({1,2;3,4}, 0.5, "pmf", 0)

Expected output:

Result
0.2399 0.1455
0.0883 0.0536

Python Code

from scipy.stats import planck as scipy_planck

def planck(k, lambda_, planck_mode='pmf', loc=0):
    """
    Compute Planck distribution values using scipy.stats.planck.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.planck.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        k (list[list]): Value(s) at which to evaluate the distribution, or probability value for ICDF/ISF modes.
        lambda_ (float): Shape parameter (must be > 0).
        planck_mode (str, optional): Output type for the distribution calculation. Valid options: PMF, CDF, SF, ICDF, ISF, Mean, Variance, Std Dev, Median. Default is 'pmf'.
        loc (float, optional): Location parameter that shifts the distribution. Default is 0.

    Returns:
        float: Distribution result (float), or error message string.
    """
    # Validate lambda_
    try:
        lam_val = float(lambda_)
        if lam_val <= 0:
            return "Invalid input: lambda must be > 0."
    except (TypeError, ValueError):
        return "Invalid input: lambda must be a number."

    # Validate loc
    try:
        loc_val = float(loc)
    except (TypeError, ValueError):
        return "Invalid input: loc must be a number."

    # Validate mode
    valid_modes = {"pmf", "cdf", "sf", "icdf", "isf", "mean", "var", "std", "median"}
    if not isinstance(planck_mode, str) or planck_mode not in valid_modes:
        return f"Invalid input: planck_mode must be one of {sorted(valid_modes)}."

    # Handle statistics (independent of k)
    if planck_mode in ["mean", "var", "std", "median"]:
        if planck_mode == "mean":
            return float(scipy_planck.mean(lam_val, loc=loc_val))
        if planck_mode == "var":
            return float(scipy_planck.var(lam_val, loc=loc_val))
        if planck_mode == "std":
            return float(scipy_planck.std(lam_val, loc=loc_val))
        if planck_mode == "median":
            return float(scipy_planck.median(lam_val, loc=loc_val))

    # Helper to compute for a single value
    def compute(val):
        try:
            kval = float(val)
        except (TypeError, ValueError):
            return "Invalid input: k must be a number."

        if planck_mode == "pmf":
            return float(scipy_planck.pmf(kval, lam_val, loc=loc_val))
        elif planck_mode == "cdf":
            return float(scipy_planck.cdf(kval, lam_val, loc=loc_val))
        elif planck_mode == "sf":
            return float(scipy_planck.sf(kval, lam_val, loc=loc_val))
        elif planck_mode == "icdf":
            return float(scipy_planck.ppf(kval, lam_val, loc=loc_val))
        elif planck_mode == "isf":
            return float(scipy_planck.isf(kval, lam_val, loc=loc_val))
        return "Unknown mode"

    # Handle k (scalar or 2D list)
    if isinstance(k, list):
        result = []
        for row in k:
            if not isinstance(row, list):
                return "Invalid input: k must be a scalar or 2D list."

            result_row = []
            for val in row:
                out = compute(val)
                if isinstance(out, str):
                    return out
                result_row.append(out)
            result.append(result_row)
        return result
    else:
        return compute(k)

Online Calculator